<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="t_title" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="i_title('')" type='success' size="mini"><i class='fa fa-check'></i>发送</el-button>
      <el-button @click="set_title('')" type='success' size="mini"><i class='fa fa-check'></i>设置保存</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 增加系统任务 </span>
      </div>
      <div>
        <input type="hidden" id="parent_id" name="parent_id" :value="param.parent_id">
        <el-row>
          <el-col :span="12">
            <el-form-item label="任务类型" prop="task_type">
              <el-select style='width:100%' v-model="t_title.set_type">
                <el-option label="提醒" value="1" />
                <el-option label="任务" value="2" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="描述" prop="task_title">
              <el-input v-model="t_title.set_title" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="优先级" prop="task_level">
              <el-select style='width:100%' v-model="t_title.set_level">
                <el-option label="一般" value="8" />
                <el-option label="加急" value="6" />
                <el-option label="特急" value="2" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="共享" prop="task_share">
              <el-radio-group v-model="t_title.set_share">
                <el-radio-button label="公共的">公共的</el-radio-button>
                <el-radio-button label="个人的">个人的</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="执行人" prop="set_man">
              {{t_title.set_man}}
              <el-button @click="popSelectionPersonnelAut('set_man','task_man')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="检测人" prop="set_aman">
              {{t_title.set_aman}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="验收人" prop="set_approvalman">
              {{t_title.set_approvalman}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="内容" prop="task_des">
              <el-input type="textarea" v-model="t_title.set_des" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始时间" prop="task_begindate">
              <el-date-picker v-model="t_title.task_begindate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="关联联系人" prop="set_relation">
              {{t_title.set_relation}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="i_title('')" type='success' size="mini"><i class='fa fa-check'></i>发送</el-button>
    </el-form>
    <el-dialog :visible.sync="SelectionPersonnelAutVisible" append-to-body>
      <SelectionPersonnelAut v-if="SelectionPersonnelAutVisible" ref="SelectionPersonnelAut" :popparams="popparams"> </SelectionPersonnelAut>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectionPersonnelAut from "@/views/crm/autooffice/SelectionPersonnelAut";
  export default {
    name: 'AddTaskReminders',
    components: {
      SelectionPersonnelAut,
    },
    props: ['popparams'],
    data() {
      return {
        SelectionPersonnelAutVisible: false,
        SelectionPersonnelAutValue: null,
        SelectionPersonnelAutDesc: null,
        vueparams: this.getVUEParams(""),
        t_title: {
          set_type: null,
          set_title: null,
          set_level: null,
          set_share: null,
          set_man: null,
          set_aman: null,
          set_approvalman: null,
          set_des: null,
          task_begindate: null,
          set_relation: null,
        },
        loading: false,
        rules: {
          task_title: [{
            required: true,
            message: "描述不能为空",
            trigger: 'blur',
          }],
          task_begindate: [{
            required: true,
            message: "开始时间不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/SubsidiaryInfo/addTaskReminders?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      set_title(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/SubsidiaryInfo/set_title?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      i_title(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/SubsidiaryInfo/i_title?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/SubsidiaryInfo/subsidiaryInfo?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      updatetime(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/SubsidiaryInfo/updatetime?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popSelectionPersonnelAut(desc, value) {
        this.SelectionPersonnelAutVisible = true;
        this.SelectionPersonnelAutDesc = desc;
        this.SelectionPersonnelAutValue = value;
      },
      closeSelectionPersonnelAut(value, desc) {
        this.SelectionPersonnelAutVisible = false;
        this.$set(this.t_title, this.SelectionPersonnelAutDesc, desc);
        this.$set(this.t_title, this.SelectionPersonnelAutValue, value);
      },
    },
  }
</script>
